package com.zz.dao;

import com.zz.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface UserMapper {
    /**
    * @Date: 14:09 2021/8/5
    * @Param: []
    * @return: java.util.List<com.zz.pojo.User>
    * @Description: 查询所有用户
    **/
   // @Select("select *from user")
    List<User> findAll();

    /**
    * @Date: 15:47 2021/8/5
    * @Param: [id]
    * @return: com.zz.pojo.User
    * @Description: 通过id查询用户 
    **/
    //@Select("select *from user where id=#{id}")
    User findById(Integer id);
    /**
    * @Date: 16:18 2021/8/5
    * @Param: [name, sex]
    * @return: java.util.List<com.zz.pojo.User>
    * @Description: 根据姓名和性别模糊查询
    **/
    //@Select("select *from user where name like concat('%',#{name},'%') and sex like concat('%',#{sex},'%') ")
    List<User> findNameAndSex(@Param("name")String name,@Param("sex") String sex);

    /**
    * @Date: 16:45 2021/8/5
    * @Param: [id, name]
    * @return: com.zz.pojo.User
    * @Description: 更新某个用的名字
    **/
    //@Update("update user set name=#{name} where id=#{id}")
    int updateName(@Param("id") Integer id,@Param("name") String name);

    /**
    * @Date: 17:19 2021/8/5
    * @Param: [id]
    * @return: int
    * @Description: 根据id删除某个用户
    **/
    //@Delete("delete from user where id=#{id}")
    int deleteById(Integer id);

    /**
    * @Date: 17:29 2021/8/5
    * @Param: [id, name, username, sex, age]
    * @return: int
    * @Description: 新增用户
    **/
    //@Insert("insert into user values(#{id},#{name},#{username},#{sex},#{age})")
    int insertUser(@Param("id") Integer id,@Param("name") String name, @Param("username")String username, @Param("sex")String sex, @Param("age")Integer age);
}
